package com.bilin.coin.adapter;

import com.bilin.coin.common.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class MyPagerAdapter extends FragmentPagerAdapter {

    private ArrayList<BaseFragment> mFragmentList = new ArrayList<>();
    private String[] mTitles = {
            "商品", "商家"
    };

    public MyPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public MyPagerAdapter(FragmentManager fm, List<BaseFragment> list) {
        super(fm);
        mFragmentList.addAll(list);
    }

    public MyPagerAdapter(FragmentManager fm, List<BaseFragment> list, String[] mTitles) {
        super(fm);
        mFragmentList.addAll(list);
        this.mTitles = mTitles;
    }

    @Override
    public Fragment getItem(int i) {
        return mFragmentList.get(i);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
